package com.zpark.dao.impl;

import com.zpark.dao.IAccountDao;
import com.zpark.pojo.Account;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

/**
 * 账户持久层接口实现类
 */
@Repository
public class AccountDaoImpl implements IAccountDao {

    @Autowired
    private QueryRunner queryRunner;

    @Override
    public List<Account> finAll() throws SQLException {
        String sql = "select id, uid, money from account";
        List<Account> query = queryRunner.query(sql, new BeanListHandler<Account>(Account.class));
        return query;
    }
}
